'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = (app) => {
  const { router, controller } = app;
  const preRouter = '/api/web';
  // 引入中间件验证token  需要验证的在路由写入token
  // const authorization = app.middleware.authorization();

  /* 轮播图分组模块 */
  router.post(
    preRouter + '/carouselGroup/create',

    controller.web.carouselGroup.create
  );
  router.delete(
    preRouter + '/carouselGroup/delete/:id',

    controller.web.carouselGroup.delete
  );
  router.put(
    preRouter + '/carouselGroup/update/:id',

    controller.web.carouselGroup.update
  );
  router.get(
    preRouter + '/carouselGroup/get',
    controller.web.carouselGroup.get
  );
  router.get(
    preRouter + '/carouselGroup/getAllCarouselGroup',
    controller.web.carouselGroup.getAllCarouselGroup
  );

  /* 轮播图模块 */
  router.post(
    preRouter + '/carousel/create',

    controller.web.carousel.create
  );
  router.delete(
    preRouter + '/carousel/delete/:id',

    controller.web.carousel.delete
  );
  router.get(preRouter + '/carousel/get', controller.web.carousel.get);
  router.put(
    preRouter + '/carousel/update/:id',

    controller.web.carousel.update
  );
  router.get(preRouter + '/carousel/getAll', controller.web.carousel.getAll);

  /* 案例模块 */
  router.post(
    preRouter + '/case/create',

    controller.web.case.create
  );
  router.delete(
    preRouter + '/case/delete/:id',

    controller.web.case.delete
  );
  router.put(
    preRouter + '/case/update/:id',

    controller.web.case.update
  );
  router.get(
    preRouter + '/case/getAll',

    controller.web.case.getAll
  );
  router.get(
    preRouter + '/case/getById',

    controller.web.case.getById
  );

  /* 分类模块 */
  router.post(
    preRouter + '/classify/create',

    controller.web.classify.create
  );
  router.delete(
    preRouter + '/classify/delete/:id',

    controller.web.classify.delete
  );
  router.put(
    preRouter + '/classify/update/:id',

    controller.web.classify.update
  );
  router.get(
    preRouter + '/classify/getAll',

    controller.web.classify.getAll
  );
  router.get(
    preRouter + '/classify/getById',

    controller.web.classify.getById
  );

  /* 新闻模块 */
  router.post(
    preRouter + '/news/create',

    controller.web.news.create
  );
  router.delete(
    preRouter + '/news/delete/:id',

    controller.web.news.delete
  );
  router.put(
    preRouter + '/news/update/:id',

    controller.web.news.update
  );
  router.get(preRouter + '/news/getAll', controller.web.news.getAll);
  router.get(preRouter + '/news/getById', controller.web.news.getById);

  /* 招聘模块 */
  router.post(
    preRouter + '/recruit/create',

    controller.web.recruit.create
  );
  router.delete(
    preRouter + '/recruit/delete/:id',

    controller.web.recruit.delete
  );
  router.put(
    preRouter + '/recruit/update/:id',

    controller.web.recruit.update
  );
  router.get(preRouter + '/recruit/getAll', controller.web.recruit.getAll);
  router.get(preRouter + '/recruit/getById', controller.web.recruit.getById);

  /* 人物模块 */
  router.post(
    preRouter + '/character/create',

    controller.web.character.create
  );
  router.delete(
    preRouter + '/character/delete/:id',
    controller.web.character.delete
  );
  router.put(
    preRouter + '/character/update/:id',

    controller.web.character.update
  );
  router.get(preRouter + '/character/getAll', controller.web.character.getAll);
  router.get(
    preRouter + '/character/getById',
    controller.web.character.getById
  );

  /* 关于我们模块 */
  router.post(
    preRouter + '/aboutUs/create',

    controller.web.aboutUs.create
  );
  router.delete(
    preRouter + '/aboutUs/delete/:id',

    controller.web.aboutUs.delete
  );
  router.put(
    preRouter + '/aboutUs/update/:id',

    controller.web.aboutUs.update
  );
  router.get(preRouter + '/aboutUs/getAll', controller.web.aboutUs.getAll);
  router.get(preRouter + '/aboutUs/getById', controller.web.aboutUs.getById);

  /* 留言模块 */
  router.post(
    preRouter + '/staymsg/create',

    controller.web.stayMsg.create
  );
  router.get(
    preRouter + '/staymsg/get',

    controller.web.stayMsg.get
  );

  /* 图片模块**/
  router.post(
    preRouter + '/imgFileUpload',

    controller.web.file.imgFileUpload
  );
};
